/**
 * Copyright (C) Skywares Information Technology, LTD. 
 * All Rights Reserved.
 *
 * TestResource.java created on 2019年11月22日 下午12:29:46 by Lyon Lu
 */
package com.mvc.server.api;

import java.util.ArrayList;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.mvc.server.client.FluxServerClient;
import com.mvc.server.component.RedisService;
import com.mvc.server.miaosha.rabbitmq.MQSender;
import com.mvc.server.miaosha.service.UserService;
import com.mvc.server.result.CommonObject;
import com.mvc.server.result.CommonResult;

import brave.Tracer;

/**
 * <pre>
 * Description:
 * 
 * @author Lyon Lu
 * @date 2019年11月22日 下午12:29:46
 *
 * </pre>
 */
@RestController
public class TestResource {
	
	@Resource
	private UserService userService;
	
	@Resource
	private RedisService redisService;
	
	@Resource
	private MQSender mqSender;
	
	@Resource
	private FluxServerClient fluxServerClient;
	
	@Resource
	private Tracer tracer;
	
	@RequestMapping(value = "test")
	public CommonResult<String> test(@RequestBody CommonObject qo){
		userService.getById(501);
		return CommonResult.success("mvc success");
	}
	
	@GetMapping(value = "mq")
	public CommonResult<String> mqTest(){
		
		mqSender.send("mq test");
		
		return CommonResult.success("mq test");
	}
	
	@RequestMapping(value = "item")
	public CommonObject item(@RequestBody String source){
		
		CommonObject obj = new CommonObject();
		obj.put("status", "OK");
		
		CommonObject body = new CommonObject();
		body.put("api", "测试鸭");
		
		List<CommonObject> items = new ArrayList<CommonObject>();
		CommonObject item = new CommonObject();
		item.put("itemId", "LYON01");
		items.add(item);
		body.put("items", items);
		
		obj.put("body", body);
		
		return obj;
	}
}
